package com.setup.trac.controller.common.loaders;

import java.math.BigDecimal;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.setup.trac.pojo.TipoIntervento;
import com.setup.trac.pojo.Utenti;
import com.setup.trac.pojo.condition.FindUtentiByProfilo;
import com.setup.trac.service.SearchService;
import com.setup.trac.util.SQLCondition;

public class LoadUtentiList implements HttpObjectsLoader {

	private SearchService searchService;

	public void load(HttpServletRequest request, HttpServletResponse response) {
		Utenti[] utenti = (Utenti[]) request.getSession(false).getAttribute("developerList");
		if(utenti==null){
			SQLCondition sql = new FindUtentiByProfilo(new BigDecimal(2));
			utenti = getSearchService().find(new Utenti[0],sql, Utenti.class);
			request.getSession(false).setAttribute("developerList", utenti);
		}
		utenti = (Utenti[]) request.getSession(false).getAttribute("usersList");
		if(utenti==null){
			SQLCondition sql = new FindUtentiByProfilo(new BigDecimal(3));
			utenti = getSearchService().find(new Utenti[0],sql, Utenti.class);
			request.getSession(false).setAttribute("usersList", utenti);
		}
			 
		
	}
	
	public SearchService getSearchService() {
		return searchService;
	}

	public void setSearchService(SearchService searchService) {
		this.searchService = searchService;
	}


}
